package com.caozhi.mspeoject.nb_search.controller;

import com.caozhi.mspeoject.nb_search.repository.OrderSearchRepository;
import com.woniuxy.boot.common.bean.EsOrder;
import com.woniuxy.boot.common.dto.EsOrderSearchDTO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("orderSearch")
public class OrderSearchController {
    @Autowired
    private OrderSearchRepository orderSearchRepository;
    @PostMapping("get")
    public List<EsOrder> getEsOrder(@RequestBody EsOrderSearchDTO esOrderSearchDTO) {
        System.out.println("kunkun");
        System.out.println(esOrderSearchDTO);
        if(esOrderSearchDTO.getKeyword()==null){
            return orderSearchRepository.findByNoOrNameOrPhoneOrFrameNumberOrCarNumber(null,null,null,null,null);
        }
        return  orderSearchRepository.findByNoOrNameOrPhoneOrFrameNumberOrCarNumber(esOrderSearchDTO.getKeyword(),esOrderSearchDTO.getKeyword(),esOrderSearchDTO.getKeyword(),esOrderSearchDTO.getKeyword(),esOrderSearchDTO.getKeyword());
    }
}
